package com.xrkj.b2c.controller.bus;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.xrkj.b2c.controller.common.BasicController;
import com.xrkj.b2c.model.bus.BusOrder;
import com.xrkj.b2c.model.sys.SysCustomer;
import com.xrkj.b2c.service.bus.PnrInputService;
import com.xrkj.b2c.service.sys.SysCustomerService;

/**
 * 
 * <B>系统名称：</B><BR>
 * <B>模块名称：</B><BR>
 * <B>中文类名：</B>PNR录单控制器<BR>
 * <B>概要说明：</B><BR>
 * @author 赵子靖
 * @since 2018年7月6日
 */
@RequestMapping("/pnr")
@Controller
public class PnrInputController extends BasicController{
    @Resource
    private PnrInputService pnrInputService;
    @Resource
    private SysCustomerService customerService;

    /**
     * 
     * <B>方法名称：</B>跳转入单pnr页面<BR>
     * <B>概要说明：</B><BR>
     * @author perry
     * @since 2018年7月6日 	
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/forwardPnrInput")
    public ModelAndView forwardPnrInput(HttpServletRequest request, HttpServletResponse response) {
        return new ModelAndView("WEB-INF/pages/bus/pnr/pnr-input");
    }
    
    /**
     * 
     * <B>方法名称：</B>根据解析结果输入订单<BR>
     * <B>概要说明：</B><BR>
     * @author perry
     * @since 2018年7月6日 	
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/forwardOrderInput")
    public ModelAndView forwardOrderInput(HttpServletRequest request, HttpServletResponse response) {
        return new ModelAndView("WEB-INF/pages/bus/pnr/order-input");
    }
    
    /**
     * 
     * <B>方法名称：</B>pnr解析<BR>
     * <B>概要说明：</B><BR>
     * @author perry
     * @since 2018年7月11日 	
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/parserPnrContent")
    public ModelAndView parserPnrContent(HttpServletRequest request, HttpServletResponse response) {
        String pnrContent = request.getParameter("pnrContent");
        List<BusOrder> pnrs = pnrInputService.parsePnrContent(pnrContent);
        request.setAttribute("pnrs", pnrs);
        //客户列表
        List<SysCustomer> customers = customerService.findCustomerList(null);
        request.setAttribute("customers", customers);
        return new ModelAndView("WEB-INF/pages/bus/pnr/order-input");
    }
    
}
